package com.vcit.clazzGroup.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vcit.common.utils.poi.ExcelUtil;
import com.vcit.system.domain.TGroupClazzs;
import com.vcit.system.service.ITGroupClazzsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vcit.common.annotation.Log;
import com.vcit.common.core.controller.BaseController;
import com.vcit.common.core.domain.AjaxResult;
import com.vcit.common.enums.BusinessType;
import com.vcit.common.core.page.TableDataInfo;

/**
 * 班级群班级关系Controller
 * 
 * @author dff
 * @date 2025-01-17
 */
@Api("班级群班级关系管理")
@RestController
@RequestMapping("/system/group/clazz")
public class TGroupClazzsController extends BaseController
{
    @Autowired
    private ITGroupClazzsService tGroupClazzsService;

    /**
     * 查询班级群班级关系列表
     */
    @ApiOperation("获取班级群班级关系列表")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:list')")
    @GetMapping("/list")
    public TableDataInfo list(TGroupClazzs tGroupClazzs)
    {
        startPage();
        List<TGroupClazzs> list = tGroupClazzsService.selectTGroupClazzsList(tGroupClazzs);
        return getDataTable(list);
    }

    /**
     * 导出班级群班级关系列表
     */
    @ApiOperation("导出班级群班级关系列表")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:export')")
    @Log(title = "班级群班级关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TGroupClazzs tGroupClazzs)
    {
        List<TGroupClazzs> list = tGroupClazzsService.selectTGroupClazzsList(tGroupClazzs);
        ExcelUtil<TGroupClazzs> util = new ExcelUtil<TGroupClazzs>(TGroupClazzs.class);
        util.exportExcel(response, list, "班级群班级关系数据");
    }

    /**
     * 获取班级群班级关系详细信息
     */
    @ApiOperation("获取班级群班级关系详细信息")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tGroupClazzsService.selectTGroupClazzsById(id));
    }

    /**
     * 新增班级群班级关系
     */
    @ApiOperation("新增班级群班级关系")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:add')")
    @Log(title = "班级群班级关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGroupClazzs tGroupClazzs)
    {
        return toAjax(tGroupClazzsService.insertTGroupClazzs(tGroupClazzs));
    }

    /**
     * 批量添加班级到班级群
     */
    @ApiOperation("批量添加班级到班级群")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:add')")
    @Log(title = "班级群班级关系", businessType = BusinessType.INSERT)
    @PostMapping("/batchAdd")
    public AjaxResult batchAdd(@RequestBody BatchAddClazzsRequest request)
    {
        return toAjax(tGroupClazzsService.batchAddClazzsToGroup(request.getCgId(), request.getClazzIds()));
    }

    /**
     * 修改班级群班级关系
     */
    @ApiOperation("修改班级群班级关系")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:edit')")
    @Log(title = "班级群班级关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGroupClazzs tGroupClazzs)
    {
        return toAjax(tGroupClazzsService.updateTGroupClazzs(tGroupClazzs));
    }

    /**
     * 删除班级群班级关系
     */
    @ApiOperation("删除班级群班级关系")
    @PreAuthorize("@ss.hasPermi('system:group:clazz:remove')")
    @Log(title = "班级群班级关系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tGroupClazzsService.deleteTGroupClazzsByIds(ids));
    }
} 